
<template>
  <div  class="main-div">
    <el-button type="primary" @click="getData" >新增</el-button>
    <fm-generate-form
      :data="jsonData"
      :remote="remoteFuncs"
      :value="editData"
      :remote-option="dynamicData"
      ref="generateForm"
    >
    </fm-generate-form>
  </div>


</template>

<script>
  import {getHisTaskData,getBpmnModelCategory} from "@/api/analy"
  import Footer from '../../../common/footer'

  export default {
    name: 'Task',
    components:{
      Footer
    },

    data() {
      return {
        jsonData:
          {
            "list": [
              {
                "type": "userDialog",
                "name": "人员选择器",
                "icon": "icon-diy-com-textarea",
                "controlType": "",
                "options": {
                  "show": true,
                  "unit": "",
                  "chooseFiledList": [

                  ],
                  "customDialogAlias": "",
                  "selectorType": "user-selector",
                  "btnName": "选择",
                  "icon": "fa fa-slack",
                  "dateCalculation": false,
                  "isSingle": true,
                  "dateCalculationStart": "",
                  "dateCalculationEnd": "",
                  "dateCalcDiffType": "",
                  "defaultValue": "",
                  "required": false,
                  "dataType": "string",
                  "span": 12,
                  "pattern": "",
                  "customClass": "",
                  "disabled": false,
                  "showRed": false,
                  "remoteFunc": "func_1588853828335",
                  "remoteOptions": []
                },
                "key": "1588853828335",
                "model": "userDialog_1588853828335",
                "rules": []
              }
            ],
            "config": {
              "labelWidth": 100,
              "labelPosition": "right",
              "size": "small",
              "customClass": "",
              "formName": "表单名称",
              "formNumber": "1588853827100279561"
            }
          }
        ,
        editData: {
          "userDialog_1588853828335": [
            {
              "lable": "王文",
              "key": "010"
            },
            {
              "lable": "王胖子",
              "key": "009"
            },
            {
              "lable": "赵六",
              "key": "001"
            },
            {
              "lable": "赵云",
              "key": "002"
            },
            {
              "lable": "李白",
              "key": "003"
            },
            {
              "lable": "貂蝉",
              "key": "004"
            },
            {
              "lable": "王飞",
              "key": "005"
            },
            {
              "lable": "马化腾",
              "key": "006"
            },
            {
              "lable": "马云",
              "key": "007"
            },
            {
              "lable": "张三",
              "key": "011"
            }
          ]

        },
        remoteFuncs: {},
        dynamicData: {},
        tableData: [],
        tableHeight: 450,
        total: 0,
        chartVisible: false,
        chartData: {},
        sellerId: 0,
        queryDate:[],
        shopName: [],
        queryForm: {
          name: "",
          createTime: "",
          page: 0,
          limit: 10,
          whereSql: "",
          typeKey: ""
        },
        categoryData: [
        ]
      }
    },
    mount() {
      this.getData()
      this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop
    },
    created() {
      this.getData()
    },
    methods: {
      queryFormCreateTime:function(e){
        this.queryForm.createTime=e;
      },
      refreshTask:function(data){
        if (data[0].parentId=='-1'){
          this.queryForm.typeKey=""
        } else{
          this.queryForm.typeKey=data[0].typeKey;

        }

        this.queryForm.createTime=""
        this.queryDate = [];
        this.queryForm.whereSql = "";
        this.getData()

      },
      queryMethod:function(){
       var name=  this.queryForm.name;
       var whereSql='';
       var createTime=  this.queryForm.createTime;
       if (createTime ){
         if (createTime[0]){
           whereSql="  and  startTime   between '"+createTime[0]+"' and "+"'"+createTime[1]+"'";
         }

       }
       this.queryForm.whereSql=whereSql;
        getHisTaskData(this.queryForm).then((response) => {
          this.tableData = response.data
          if (response.count.length>0){
            this.total = parseInt(response.count);
          }else{
            this.total=0;
          }

        })

      },

      getData: function () {
        this.$refs.generateForm.getData().then(data => {
          // Data verification succeeded
          alert(JSON.stringify(data))
        }).catch(e => {
        });
      },
      handleCurrentChange(val) {
        this.queryForm.page = val
        this.getData()
      },

      search() {
        this.queryForm.page = 0
        this.queryMethod()
      },
      reset() {
        this.queryForm.name = "";
        this.queryForm.createTime = "";
        this.queryDate = [];
        this.queryForm.whereSql = "";
        this.getData()
      }

    }

  }

</script>
<style lang="scss">
.task-card{
  margin-top: 10px;
}

</style>
